<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改服务商档位信息（分润标准）')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-gears_info-edit" th:object="${gearsInfo}">
            <div class="form-group">
                <label class="col-sm-3 control-label">档次：</label>
                <div class="col-sm-8 input-group"><span class="input-group-addon">V</span>
                    <input name="grade" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" maxlength="2" th:field="*{grade}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">档次名称：</label>
                <div class="col-sm-8 input-group">
                    <input name="gradeName" th:field="*{gradeName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">档位：</label>
                <div class="col-sm-8 input-group">
                    <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('is_min')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">活动DS：</label>
                <div class="col-sm-8 input-group">
                    <input name="reward" th:field="*{reward}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">云闪付活动DS：</label>
                <div class="col-sm-8 input-group">
                    <input name="rewardYsf" th:field="*{rewardYsf}" class="form-control" required type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">活动DS过期日期：</label>
                <div class="col-sm-8 input-group">
                    <input name="rewardEndDate" th:field="*{rewardEndDate}" readonly class="form-control" placeholder="yyyy-MM-dd" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">月交易量区间：</label>
                <div class="col-sm-8 input-group">
                    <input name="startMoney" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" maxlength="18" th:value="${startMoney}" class="form-control" placeholder="起始金额" type="text">至<input name="endMoney" th:value="${endMoney}" placeholder="结束金额" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" maxlength="18" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">消费DS：</label>
                <div class="col-sm-8 input-group">
                    <input name="ds"  th:field="*{ds}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">云闪付：</label>
                <div class="col-sm-8 input-group">
                    <input name="ysf"  th:field="*{ysf}" required class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">排序：</label>
                <div class="col-sm-8 input-group">
                    <input  name="sorts"   th:field="*{sorts}"  required class="form-control" type="number">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "gears_info/gears_info";
        $("#form-gears_info-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var startMoney = Number($("input[name='startMoney']").val());
                var endMoney = Number($("input[name='endMoney']").val());
                if (startMoney > endMoney){
                    $.modal.alertWarning("起始金额不能大于结束金额");
                    return;
                }
                var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
                if (!reg.test(startMoney)) {
                    $.modal.alertWarning("请输入正确的起始金额");
                    return;
                } else if (!reg.test(endMoney)){
                    $.modal.alertWarning("请输入正确的结束金额");
                    return;
                }
                $.operate.save(prefix + "/edit", $('#form-gears_info-edit').serialize());
            }
        }

        $("input[name='rewardEndDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>